package chapter7.section2;

//程序7-2:利用异常捕获机制捕获可能的NullPointerException异常
public class Summer2 {
	public static int summer2(int[] score) {
		int amount = 0;
		try {
			for (int i = 0; i < score.length; i++) {
				amount += score[i];
			}
		} catch (NullPointerException e) {
			System.out.println("不能给我一个null的参数！");
		}
		return amount;
	}
  
	public static void main(String[] args) {
		int[] score = null;
		int result = summer2(score);
	}
}
